#include <iostream>

using namespace std;

const int N = 1e5 + 10;

typedef long long LL;

LL f[N];
int n, m;
LL ret;

int main()
{
    cin >> n >> m;
    int x, y; cin >> x;
    for(int i = 2; i <= m; i++)
    {
        cin >> y;
        if(x < y)
        {
            f[x]++;
            f[y]--;
        }
        if(x > y)
        {
            f[y]++;
            f[x]--;
        }
        x = y;
    }

    // 利用差分数组，还原出原数组
    for(int i = 1; i <= n; i++) f[i] += f[i - 1];
    
    for(int i = 1; i <= n - 1; i++)
    {
        LL a, b, c; cin >> a >> b >> c;
        ret += min(a * f[i], c + b * f[i]);
    }
    cout << ret << endl;
    return 0;
}